< previous page page_299 next page >

Page 299
Here are a couple of Boolean expressions:
Dim A As Boolean, B As Boolean
A = True
B = Not True
What is the value of B? False, of course. It's logical: Anything that is not True must be False. Boolean algebra is a lot like thatmostly common sense.
We use a special kind of table, called a truth table, to determine the results of a Boolean operation. The truth table for the NOT operation is shown below:
VARIABLE ARESULT (NOT A)
TrueFalse
FalseTrue
The NOT Operation

The first column contains all of the possible values for the variable. The result is what you get after you apply the operation. Thus, Not True = False, Not False = True.
The NOT operator is the easiest one. There are three Boolean operators in Visual Basic that use two variables: the AND, OR, and XOR operators.
The truth tables for these operators are as follows:
VARIABLE AVARIABLE BRESULT (A AND B)
FalseFalseFalse
FalseTrueFalse
TrueFalseFalse
TrueTrueTrue
The AND Operation
VARIABLE AVARIABLE BRESULT (A OR B)
FalseFalseFalse
FalseTrueTrue
TrueFalseTrue
TrueTrueTrue
The OR Operation

 
< previous page page_299 next page >